/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */


struct ListNode* removeNthFromEnd(struct ListNode* head, int n){
    int i = 0;
    struct ListNode* si = head;
    struct ListNode* ss = head;
    for(i = 0;i < 30;i++){
        if(si == NULL){
            break;
        }
        si = si->next;
    }
    int sz = i;
    printf("%d",sz);
    int xz = sz-n;
    printf("%d",xz);
    if(sz == 1){
        return NULL;
    }else if(xz == 0){
            head = head->next;
            return head;
    }else{
        for(i = 1;i<sz; i++){
            if(i == xz){
                ss->next = ss->next->next;
                return head;
            }
            ss=ss->next;
        }
    }
    return head;
}
